< previous page page_660 next page >

Page 660
Of course, because the DragOver event is called repeatedly as the mouse is dragged over the control, you need to set a flag to inform the DragOver event that the DragIcon property has already been changed to the no drop icon. For this, you can use a module-level variable.
EXERCISE
Stopping the Drop of a Control
1. Add a module-level variable to this form called mboolFlag as a Boolean data type.
2. In the Form_Load() event, set this variable to True:
Sub Form_Load()
mboolFlag = True
End Sub
3. Double-click on the txtNoDrop text box.
4. Locate the DragOver() event in the Procedures combo Box.
5. Add the following code:
Sub txtNoDrop_DragOver (Source As Control, X As Single, _
Y As Single, State As Integer)
If mboolFlag Then
If State = vbEnter Or State = vbOver Then
Source.DragIcon = LoadPicture("trffc14.ico")
mboolFlag = False
End If
Else
If State = vbLeave Then
Source.DragIcon = LoadPicture("bullseye.ico")
mboolFlag = True
End If
End If
End Sub
analysis.gifEvery time the dragged control enters the text box, the DragIcon property of the control being dragged is changed. You use the LoadPicture() function to load a new icon into the property. You then set a module-level variable mboolFlag to indicate that youve already loaded the icon. By setting this flag, you wont keep loading the icon over and over again as this event keeps firing. For when the control moves out of the text

 
< previous page page_660 next page >

If you like this book, buy it!